<?php

class Pages extends CI_Controller {

	public function view($page = 'home')
	{
		$this->data['seo_title'] = '';
		$this->data['seo_description'] = '';
		$this->data['seo_keywords'] = '';
		
		// incarcam formularul de login doar daca utilizatorul nu este conectat
		if(!$this->session->userdata('is_logged_in')) {
			$login = $this->load->view('login', '', true);
			$this->data['login'] = $login;
		}
		
		$this->load->model('model_pages');
		
		if ( !$this->model_pages->get_page($page) )
		{
			show_404();
		}
		$this->data['page'] = $this->model_pages->get_page($page);
		$this->data['pg'] = $page;
		
		$this->load->model('model_faq');
		$this->data['faqs']=$this->model_faq->get_faq();
		
		$this->load->view('general/header', $this->data);
		$this->load->view("pages/default_page", $this->data);
		$this->load->view('general/footer', $this->data);
	}
	
	public function contact_validation($pg) {
		$this->load->library('form_validation');
		
		// validare formular
		$this->form_validation->set_rules('message', 'Parola', 'required|trim');
	
		if($this->form_validation->run()) {		
			$this->load->library('email', array('mailtype'=>'html'));
			$this->email->from('ParKing.ro');
			$this->email->to('contact@parking.ro');
			
			$this->email->subject("Mesaj nou site");
			
			$message = $this->input->post('message');
			
			$this->email->message($message);
		}
	}
}